//
//  RCAboutVC.m
//  RocketProject
//
//  Created by Wu Chengwei on 13-6-22.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCAboutVC.h"
#import "UIColor-Expanded.h"
#import "CommonDefines.h"
#import "TTTAttributedLabel.h"
#import "NSAttributedString+LVAddition.h"

#define kLogoImageFile               @"image_about_logo.png"
#define kWebsiteImageFile            @"image_about_website.png"
#define kEmailImageFile              @"image_about_email.png"
#define kPhoneImageFile              @"image_about_phone.png"
#define kTextBGImageFile             @"image_about_textBG.png"

@interface RCAboutVC ()

@end

@implementation RCAboutVC

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(void)loadView{
    [super loadView];
    self.titleLabelText = @"关于我们";
    self.navigationItem.titleView = [self createTitleView];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    NSString *resourcePath = [[NSBundle mainBundle]resourcePath];
    UIImageView *logoImageView = [[UIImageView alloc]initWithFrame:CGRectMake(122, 20, 77, 45)];
    logoImageView.backgroundColor = [UIColor clearColor];
    NSString *logoFilePath = [resourcePath stringByAppendingPathComponent:kLogoImageFile];
    [logoImageView setImage:[UIImage imageWithContentsOfFile:logoFilePath]];
    [self.viewContainer addSubview:logoImageView];
    [logoImageView release];
    
    UIImageView *textBGImageView = [[UIImageView alloc]initWithFrame:CGRectMake(14, 85, 292, 213)];
    textBGImageView.backgroundColor = [UIColor clearColor];
    NSString *textBGFilePath = [resourcePath stringByAppendingPathComponent:kTextBGImageFile];
    UIImage *textBGImage = [UIImage imageWithContentsOfFile:textBGFilePath];
    textBGImage = [textBGImage resizableImageWithCapInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
    [textBGImageView setImage:textBGImage];
    
    UILabel *redTextLabel = [[UILabel alloc]initWithFrame:CGRectMake(16, 15, 100, 12)];
    redTextLabel.backgroundColor = [UIColor clearColor];
    redTextLabel.textColor = [UIColor colorWithHex:0xffea5529];
    redTextLabel.font = [UIFont fontWithName:kFontNameLightHeiti size:12];
    redTextLabel.text = @"如意行商务服务网";
    
    CGSize size = [redTextLabel.text sizeWithFont:redTextLabel.font constrainedToSize:CGSizeMake(200, 50)];
    redTextLabel.frame = CGRectMake(16, 15, size.width, 12);
    [textBGImageView addSubview:redTextLabel];
    [redTextLabel release];
    
    UILabel *firstRestLabel = [[UILabel alloc]initWithFrame:CGRectMake(16+size.width, 15, 260-size.width, 12)];
    firstRestLabel.backgroundColor = [UIColor clearColor];
    firstRestLabel.textColor = [UIColor colorWithHex:0xff505050];
    firstRestLabel.font = [UIFont fontWithName:kFontNameLightHeiti size:12];
    firstRestLabel.text = @"是专业为商务、休闲、出游人";
    [textBGImageView addSubview:firstRestLabel];
    [firstRestLabel release];
    
    TTTAttributedLabel *restLabel = [[TTTAttributedLabel alloc]initWithFrame:CGRectMake(16, 33, 260, 200)];
    restLabel.backgroundColor = [UIColor clearColor];
    restLabel.textColor = [UIColor colorWithHex:0xff505050];
    restLabel.font = [UIFont fontWithName:kFontNameLightHeiti size:12];
    restLabel.numberOfLines = 0;
    restLabel.leading = 6;
    restLabel.text = @"士精心打造的第三方独立咨询及网络服务定制平台，提供商务人士到达一个新城市后所需要的所有服务。";
    NSAttributedString *attributedStr = restLabel.attributedText;
    CGSize restSize = [attributedStr sizeWithConstrainedToSize:CGSizeMake(260, 2000) Leading:6];
    restLabel.frame = CGRectMake(16, 33, 260, restSize.height);
    [textBGImageView addSubview:restLabel];
    [restLabel release];
    
    CGFloat currentHeight = 33+restSize.height+18;
    
    UIImageView *websiteImageView = [[UIImageView alloc]initWithFrame:CGRectMake(16, currentHeight, 13, 13)];
    NSString *websitePath = [resourcePath stringByAppendingPathComponent:kWebsiteImageFile];
    [websiteImageView setImage:[UIImage imageWithContentsOfFile:websitePath]];
    [textBGImageView addSubview:websiteImageView];
    [websiteImageView release];
    
    UILabel *websiteLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(34, currentHeight+1, 220, 12)];
    websiteLabel1.backgroundColor = [UIColor clearColor];
    websiteLabel1.font = [UIFont fontWithName:kFontNameLightHeiti size:12];
    websiteLabel1.textColor = [UIColor colorWithHex:0xff505050];
    websiteLabel1.text = @"官网：";
    CGSize websiteSize = [websiteLabel1.text sizeWithFont:websiteLabel1.font constrainedToSize:CGSizeMake(200, 12)];
    websiteLabel1.frame = CGRectMake(34, currentHeight+1, websiteSize.width, 12);
    [textBGImageView addSubview:websiteLabel1];
    [websiteLabel1 release];
    
    UILabel *websiteLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(34+websiteSize.width, currentHeight+1, 220-websiteSize.width, 12)];
    websiteLabel2.backgroundColor = [UIColor clearColor];
    websiteLabel2.font = [UIFont fontWithName:kFontNameHelvetica size:12];
    websiteLabel2.textColor = [UIColor colorWithHex:0xff505050];
    websiteLabel2.text = @"www.17ruyi.com";
    [textBGImageView addSubview:websiteLabel2];
    [websiteLabel2 release];
    
    currentHeight +=13+13;
    
    UIImageView *emailImageView = [[UIImageView alloc]initWithFrame:CGRectMake(16, currentHeight+2, 12, 8)];
    NSString *emailPath = [resourcePath stringByAppendingPathComponent:kEmailImageFile];
    [emailImageView setImage:[UIImage imageWithContentsOfFile:emailPath]];
    [textBGImageView addSubview:emailImageView];
    [emailImageView release];
    
    UILabel *emailLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(34, currentHeight, 220, 12)];
    emailLabel1.backgroundColor = [UIColor clearColor];
    emailLabel1.font = [UIFont fontWithName:kFontNameLightHeiti size:12];
    emailLabel1.textColor = [UIColor colorWithHex:0xff505050];
    emailLabel1.text = @"邮箱：";
    CGSize emailSize = [emailLabel1.text sizeWithFont:emailLabel1.font constrainedToSize:CGSizeMake(200, 12)];
    emailLabel1.frame = CGRectMake(34, currentHeight+1, emailSize.width, 12);
    [textBGImageView addSubview:emailLabel1];
    [emailLabel1 release];
    
    UILabel *emailLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(34+emailSize.width, currentHeight, 220-emailSize.width, 12)];
    emailLabel2.backgroundColor = [UIColor clearColor];
    emailLabel2.font = [UIFont fontWithName:kFontNameHelvetica size:12];
    emailLabel2.textColor = [UIColor colorWithHex:0xff505050];
    emailLabel2.text = @"sd17ruyi@163.com";
    [textBGImageView addSubview:emailLabel2];
    [emailLabel2 release];
    
    currentHeight +=12+13;
    
    UIImageView *phoneImageView = [[UIImageView alloc]initWithFrame:CGRectMake(16, currentHeight, 13, 12)];
    NSString *phonePath = [resourcePath stringByAppendingPathComponent:kPhoneImageFile];
    [phoneImageView setImage:[UIImage imageWithContentsOfFile:phonePath]];
    [textBGImageView addSubview:phoneImageView];
    [phoneImageView release];
    
    UILabel *phoneLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(34, currentHeight, 220, 12)];
    phoneLabel1.backgroundColor = [UIColor clearColor];
    phoneLabel1.font = [UIFont fontWithName:kFontNameLightHeiti size:12];
    phoneLabel1.textColor = [UIColor colorWithHex:0xff505050];
    phoneLabel1.text = @"电话：";
    CGSize phoneSize = [phoneLabel1.text sizeWithFont:phoneLabel1.font constrainedToSize:CGSizeMake(200, 12)];
    phoneLabel1.frame = CGRectMake(34, currentHeight+1, phoneSize.width, 12);
    [textBGImageView addSubview:phoneLabel1];
    [phoneLabel1 release];
    
    UILabel *phoneLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(34+phoneSize.width, currentHeight, 220-phoneSize.width, 12)];
    phoneLabel2.backgroundColor = [UIColor clearColor];
    phoneLabel2.font = [UIFont fontWithName:kFontNameHelvetica size:12];
    phoneLabel2.textColor = [UIColor colorWithHex:0xff505050];
    phoneLabel2.text = @"0538-8663766";
    [textBGImageView addSubview:phoneLabel2];
    [phoneLabel2 release];
    
    [self.viewContainer addSubview:textBGImageView];
    [textBGImageView release];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
